package com.duowei.diandan.bean.food;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * 单品和套餐列表
 */
public class SingleAndMeals implements FoodImpl, Serializable {
    private Single single;

    private List<Meal> mealList;

    public SingleAndMeals() {
    }

    public SingleAndMeals(Single single, List<Meal> mealList) {
        this.single = single;
        this.mealList = mealList;
    }

    public Single getSingle() {
        return single;
    }

    public void setSingle(Single single) {
        this.single = single;
    }

    public List<Meal> getMealList() {
        return mealList;
    }

    public void setMealList(List<Meal> mealList) {
        this.mealList = mealList;
    }

    @Override
    public String getImgNo() {
        return this.single.getImgNo();
    }

    @Override
    public String getName() {
        return this.single.getName();
    }

    @Override
    public Float getPrice() {
        return this.single.getPrice();
    }

    @Override
    public Float getMemberPrice() {
        return this.single.getMemberPrice();
    }

    @Override
    public Float getXl() {
        if (this.single != null) {
            return this.single.getXl();
        } else {
            return null;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof SingleAndMeals) {
            SingleAndMeals sam = (SingleAndMeals) obj;

            return Objects.equals(this.single, sam.single)
                    && this.mealList.containsAll(sam.mealList)
                    && sam.mealList.containsAll(this.mealList);
        } else {
            return false;
        }
    }
}
